package com.ms.teapuesto.util;

import org.apache.log4j.PropertyConfigurator;

import java.util.Properties;

/**
 */
public class LogUtils {



    public static void initForTest() {
        initInter("INFO, stdout");
    }
    public static void initForTestFullDebug() {
        initInter("DEBUG, stdout");
    }

    private static void initInter(String rootCategory) {
        Properties log4j = new Properties();
        log4j.put("log4j.rootCategory", rootCategory);
        log4j.put("log4j.appender.stdout", "org.apache.log4j.ConsoleAppender");
        log4j.put("log4j.appender.stdout.layout", "org.apache.log4j.PatternLayout");
        log4j.put("log4j.appender.stdout.layout.ConversionPattern", "%d{HH:mm:ss,SSS} [%10t] %-5p %-20c - %m%n");

        log4j.put("log4j.logger.com.dpwc", "DEBUG");
        log4j.put("log4j.logger.java.sql", "DEBUG");
        log4j.put("log4j.logger.org.springframework.jdbc", "DEBUG");
        log4j.put("log4j.logger.org.ajax4jsf", "WARN");

        PropertyConfigurator.configure(log4j);
    }

    public static void initForProd() {
        PropertyConfigurator.configure("WEB-INF/log4j.properties");
    }
}
